package com.lzh.persevere.controller;

import com.lzh.persevere.common.R;
import com.lzh.persevere.common.ResultUtil;
import com.lzh.persevere.model.entity.TagInfo;
import com.lzh.persevere.service.TagInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 文章标签controller
 *
 * @author luzhiheng
 * @since 2025-07-18
 */
@RestController
@RequestMapping("/tag")
@Api(tags = "文章标签")
public class TagInfoController {

    @Resource
    private TagInfoService tagInfoService;

    @ApiOperation(value = "查询标签列表")
    @PostMapping("/findTagList")
    public R<List<TagInfo>> findTagList() {
        return ResultUtil.success(tagInfoService.list());
    }

    @ApiOperation(value = "添加标签")
    @PostMapping("/addTag")
    public R<Boolean> addTag(@Valid @RequestBody TagInfo tagInfo) {
        return ResultUtil.success(tagInfoService.save(tagInfo));
    }
}
